package org.drl.tvkit.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * 倒影图片组件
 * 
 * @author dai.rui.lin
 * 
 */
public class ShadowView extends ImageView {
	private Paint paintShadow;
	public ShadowView(Context context) {
		super(context);
		init();
	}

	public ShadowView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public ShadowView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	private void init() {
		if (paintShadow == null) {
			paintShadow = new Paint();
		}
	}
	@SuppressLint("DrawAllocation")
	@Override
	protected void onDraw(Canvas canvas) {
		if (canvas != null) {
			canvas.setDrawFilter(new PaintFlagsDrawFilter(0,
					Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
//			LinearGradient shader = new LinearGradient(0,
//					0 , 0, getHeight(),
//					Color.TRANSPARENT, Color.BLACK, TileMode.REPEAT);
//			paintShadow.setShader(shader);
//			paintShadow.setXfermode(new PorterDuffXfermode(
//					Mode.DST_IN));
//			canvas.drawRect(0,5,getWidth(), getHeight(), paintShadow);
		}
		super.onDraw(canvas);
	}


}
